package cn.vin.demo;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;

import java.util.ArrayList;
import java.util.List;
@JacksonXmlRootElement(localName = "Channel")
public class Channel {
    @JacksonXmlProperty(localName = "items")
    private List<Object> items;

    public List<Object> getItems() {
        return items;
    }

    public void setItems(List<Object> items) {
        this.items = items;
    }

    public void build() {
        items = new ArrayList<>();
        items.add(new pen("a"));
        items.add(new pencil("b"));
        items.add(new paper("c"));
    }
    @JacksonXmlRootElement(localName = "pen")
    static class pen {
        @JacksonXmlProperty(localName = "name")
        private String name;

        public pen(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
    @JacksonXmlRootElement(localName = "pencil")
    static class pencil {
        @JacksonXmlProperty(localName = "name")
        private String name;

        public pencil(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
    @JacksonXmlRootElement(localName = "paper")
    static class paper {
        @JacksonXmlProperty(localName = "name")
        private String name;

        public paper(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
